<template>
	<view class="uni-tab-bar">
		<scroll-view scroll-x class="uni-swiper-tab" :style="scrollStyle">
			<view class="uni-swiper-flex">
				<block v-for="(tab,index) in tabBars" :key="tab.id">
					<view class="swiper-tab-list" 
					:class="{'active':tabIndex==index}"
					@tap="tabtap(index)"
					:style="scrollItemStyle">
						{{tab.name}} {{tab.num?tab.num:''}}
						<!-- 下划线 -->
						<view class="swiper-tab-line"></view>
					</view>
				</block>
			</view>
		</scroll-view>
		<view class="tpbottomView"></view>
	</view>
</template>

<script>
	export default {
		props:{
			tabBars:Array,
			tabIndex:Number,
			scrollStyle:{
				type:String,
				default:""
			},
			scrollItemStyle:{
				type:String,
				default:""
			}
		},
		methods:{
			tabtap(index){
				//点击tab时把自己的index传给父组件index.vue
				this.$emit('tabtap',index);
			},
		}
	}
</script>

<style >
.uni-tab-bar{
	position: relative;
}
.uni-swiper-tab{
	/* border-bottom: 1upx solid #EEEEEE; */
	height: 80upx;
	line-height: 80upx;
}
.uni-swiper-flex{
	display: flex;
}


.swiper-tab-list{
	color: #111111;
	font-size: 30upx;
	min-width: 160upx;
	height: 80upx;
	text-align: center;
	position: relative;
}

.uni-tab-bar .active{
	color: #111111;
	font-size: 36upx;
	font-weight: 550;
}

.active .swiper-tab-line{
	width: 50upx;
	height: 5upx;
	background-color: #fd393e;
	/* margin: auto; */
	position: absolute;
	bottom: 0px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 999;
}
.tpbottomView {
	position: absolute;
	background-color: #fff;
	width: 100%;
	height: 18rpx;
	bottom: 0;
	z-index: 96;
}
</style>